package com.sharding.jdbc.demo.controller;

import com.sharding.jdbc.demo.entity.TableOne;
import com.sharding.jdbc.demo.service.TableOneService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ShardController {

    @Resource
    private TableOneService shardService ;
    /**
     * 创建表（可以自定义）
     */
    @RequestMapping("/createTable")
    public String createTable (){
        shardService.createTable();
        return "success" ;
    }
    /**
     * 往表table_one中添加数据
     */
    @RequestMapping("/insertOne")
    public String insertOne (){
        shardService.insertOne();
        return "SUCCESS" ;
    }
    /**
     * 查询表table_one指定的数据
     */
    @RequestMapping("/selectOneByPhone/{phone}")
    public List<TableOne> selectOneByPhone (@PathVariable("phone") String phone){
        return shardService.selectOneByPhone(phone);
    }

}
